home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / shell / taskmana / src / sub.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  10.5 KB  |  446 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <winb.h>
  5. #include <te.h>
  6. #include <fntb.h>
  7. #include <gui.h>
  8. #include <egb.h>
  9. #include <guidbg.h>
  10.  
  11. int    dialogID = -1 ;
  12. int    messageID[12] = -1 ;
  13. int    taskButtonID[11] = -1 ;
  14. int    dialogMenuID = -1 ;
  15. int    topMenuItemID[3] = -1 ;
  16. int    topMenuID[4] = -1 ;
  17. int    MenuItemID[9] = -1 ;
  18. int    quitIconID = -1 ;
  19. int    aboutDialogID = -1 ;
  20. int    aboutMessageID[5] = -1 ;
  21. int    aboutDButtonID = -1 ;
  22. int    dialogBaseHyperID = -1 ;
  23. int    sourceMenuID = -1 ;
  24. int    sourceMenuItemID = -1 ;
  25. int    commandDialogID = -1 ;
  26. int    commandfileDButtonID = -1 ;
  27. int    commandExecDButtonID = -1 ;
  28. int    commandFileNameTextID = -1 ;
  29. int    commandQuitIconID = -1 ;
  30. int    commandMessageID[2] = -1 ;
  31. int    commandReturnExecDButtonID = -1 ;
  32.  
  33. #include <file_dlg.h>
  34. #include <eintm.h>
  35.  
  36. //#define DEBUG
  37.  
  38. int fdlgFunc(char *);
  39.  
  40. //extern char *taskListMsg[] ;
  41. extern int taskOldID[] ;
  42. //extern int taskOldCount ;
  43. extern int    taskListUpdateFlag ;
  44. extern int    *apliID;        //アプリに対応するメニューアイテムID
  45. extern int    *apliMode;        //アプリMODE
  46. extern char    *apliPath;        //アプリパス
  47. extern int    *apliSaveFlag;    //アプリ退避フラグ(TRUE:退避中)
  48. extern int    apliNum;        //登録アプリ数
  49. //extern void    upDateTaskList(void);
  50. extern void    restartEXG(void);
  51. extern char *buf;
  52.  
  53. char *aboutMsg;
  54.  
  55. int aboutFlag = FALSE ;
  56. int alertClass=0;
  57. int alertobj[3] ;
  58.  
  59. extern int quitFuncRet ;
  60. extern int taskFlag;
  61.  
  62. /*    initDataSRCGUI:sourceMenuItemID:MJ_MITEML40の呼び出し関数    */
  63. int    apliMenuExecFunc(kobj, messId, argc, pev, trigger)
  64. int        kobj ;
  65. int        messId ;
  66. int        argc ;
  67. EVENT    *pev ;
  68. int        trigger ;
  69. {
  70.     int        i,j,k;
  71.     int        n,id;
  72.  
  73.     for(i=0;apliID[i]!=kobj;i++) ;
  74.  
  75.     #ifdef DEBUG
  76.     printf("menuItemID=%d\napliMode  =%d\napliPath  =%s\n",
  77.                                 apliID[i],apliMode[i],&(apliPath[i*128]));
  78.     #endif
  79.  
  80.     //    EXGを退避
  81.     if(apliMode[i]==2 || apliMode[i]==3 || apliMode[i]==5 || apliMode[i]==6)
  82.     {
  83.         if(apliMode[i]==3 || apliMode[i]==6) n=2; else n=1;
  84.         for(j=0;j<apliNum;j++)
  85.             if(apliMode[j]<n)
  86.             {
  87.                 EIN_fnameNonDirectory(&(apliPath[j*128]),buf);
  88.                 k=MMI_CallMessage(MMI_GetApliId(),GM_QUERYID,
  89.                                             QM_SAMEAS,( int )buf);
  90.                 if(k>0)
  91.                 {
  92.                     apliSaveFlag[j] = TRUE;
  93.                     MMI_CallMessage( k, GM_QUIT, 0, 0 ); 
  94.                 }
  95.             }
  96.     }
  97.  
  98.     if(apliMode[i]<4)
  99.     {    //    EXG起動
  100.         apliSaveFlag[i] = FALSE;
  101.         MMI_CallMessage(MMI_GetApliId(),GM_INVOKE,TRUE,
  102.                                                 (int)&(apliPath[i*128]));
  103.     } else
  104.     if(apliMode[i]<7)
  105.     {    //    オーバーレイEXP起動(同じディレクトリのGL.EXG経由)
  106.         j=i*128;
  107.         MMI_CallMessage(MMI_GetApliId(),GM_QUERYID,QM_DIRECTRY,( int )buf );
  108.         for(i=0;buf[i]!='\0';i++) ;
  109.         buf[i   ] = 'G';
  110.         buf[i+ 1] = 'L';
  111.         buf[i+ 2] = '.';
  112.         buf[i+ 3] = 'E';
  113.         buf[i+ 4] = 'X';
  114.         buf[i+ 5] = 'G';
  115.         buf[i+ 6] = ' ';
  116.         i+=7;
  117.         for(k=0;apliPath[j+k]!='\0';k++) buf[i+k] = apliPath[j+k];
  118.         buf[i+k]='\0';
  119.         #ifdef DEBUG
  120.         printf("EXP overray:%s\n",buf);
  121.         #endif
  122.         MMI_CallMessage(MMI_GetApliId(),GM_INVOKE,TRUE,(int)buf);
  123.     } else
  124.     {    //    EXP・EXE・COM・BAT起動
  125.         #ifdef DEBUG
  126.         printf("EXP・EXE・COM・BAT:%s\n",&(apliPath[i*128]));
  127.         #endif
  128.         system(&(apliPath[i*128]));
  129.     }
  130.  
  131.     return NOERR ;
  132. }
  133.  
  134. void setAlertObj(int targetobj)
  135. {
  136.     alertobj[alertClass] = MMI_GetAlertObj();    //    現在のALERTOBJを退避
  137.     ++alertClass;
  138.     MMI_SetAlertObj( targetobj ) ;
  139.  
  140.     return ;
  141. }
  142.  
  143. void resetAlertObj()
  144. {
  145.     --alertClass;
  146.     MMI_SetAlertObj( alertobj[alertClass] ) ;    //    ALERTOBJを元に戻す
  147.     return ;
  148. }
  149.  
  150. /*    initDataGUI:MenuItemID[6]:MJ_MITEML40の呼び出し関数    */
  151. int    execFunc(kobj, messId, argc, pev, trigger)
  152. int        kobj ;
  153. int        messId ;
  154. int        argc ;
  155. EVENT    *pev ;
  156. int        trigger ;
  157. {
  158.     //つないで表示
  159.     MMI_SendMessage(commandDialogID ,MM_ATTACH , 1, dialogBaseHyperID);
  160.     MMI_SendMessage(commandFileNameTextID ,MM_WAKE ,0 );
  161.     MMI_SendMessage(commandDialogID ,MM_SHOW , 0);
  162.     setAlertObj(commandDialogID);
  163.  
  164.     return NOERR ;
  165. }
  166.  
  167. //    ファイルダイアログ処理関数
  168. //    呼び出すとファイルダイアログを表示してパス名を取得
  169. int fdlgFunc(PathName)
  170. char    *PathName ;        //    パス名を格納する配列
  171. {
  172.     static char    *ExtStr[]={"*.*",NULL} ;
  173.                                                 //    ワイルドカードの指定
  174.     unsigned int    MSlctCnt ;                    //    選択されたファイル数
  175.     int                Atr ;                        //    ファイル属性 (未使用)
  176.     int                ret ;
  177.  
  178.     //    ファイルダイアログの表示
  179.     #ifdef DEBUG
  180.     printf("ファイルダイアログ表示\n");
  181.     #endif
  182.     ret=FDG_DspFileDlg(dialogBaseHyperID,
  183.             FDG_NONE|FDG_ALERT|FDG_REDRAW|FDG_TEXT
  184.                     , NULL,ExtStr, &MSlctCnt) ;
  185.     if (ret && MSlctCnt > 0) 
  186.     {    //    "読込"か"保存"が押されたならファイル名を取得する
  187.         #ifdef DEBUG
  188.         printf("ファイル名取得完了\n");
  189.         #endif
  190.         FDG_GetPathName(PathName, &Atr, 0) ;
  191.     } else
  192.     {    //    "取消"が押されたか1つもファイルが選択されなかった場合は
  193.         //    ファイル名を取得しないで終了する
  194.         ret = 0 ;
  195.     }
  196.  
  197.     //テキストWAKE
  198.     MMI_SendMessage(commandFileNameTextID ,MM_WAKE ,0 );
  199.  
  200.     return ret ;
  201. }
  202.  
  203. /*    initDataGUI:MenuItemID[5]:MJ_MITEML40の呼び出し関数    */
  204. int    restartEXGFunc(kobj, messId, argc, pev, trigger)
  205. int        kobj ;
  206. int        messId ;
  207. int        argc ;
  208. EVENT    *pev ;
  209. int        trigger ;
  210. {
  211.     restartEXG();
  212.     return NOERR ;
  213. }
  214.  
  215. /*    initDataGUI:taskButtonID[0]:MJ_BUTTONL40の呼び出し関数    */
  216. /*    initDataGUI:taskButtonID[1]:MJ_BUTTONL40の呼び出し関数    */
  217. /*    initDataGUI:taskButtonID[2]:MJ_BUTTONL40の呼び出し関数    */
  218. /*    initDataGUI:taskButtonID[3]:MJ_BUTTONL40の呼び出し関数    */
  219. /*    initDataGUI:taskButtonID[4]:MJ_BUTTONL40の呼び出し関数    */
  220. /*    initDataGUI:taskButtonID[5]:MJ_BUTTONL40の呼び出し関数    */
  221. /*    initDataGUI:taskButtonID[6]:MJ_BUTTONL40の呼び出し関数    */
  222. /*    initDataGUI:taskButtonID[7]:MJ_BUTTONL40の呼び出し関数    */
  223. /*    initDataGUI:taskButtonID[8]:MJ_BUTTONL40の呼び出し関数    */
  224. /*    initDataGUI:taskButtonID[9]:MJ_BUTTONL40の呼び出し関数    */
  225. /*    initDataGUI:taskButtonID[10]:MJ_BUTTONL40の呼び出し関数    */
  226. int    taskButtonFunc(kobj, messId, argc, pev, trigger)
  227. int        kobj ;
  228. int        messId ;
  229. int        argc ;
  230. EVENT    *pev ;
  231. int        trigger ;
  232. {
  233.     int i;
  234.  
  235.     #ifdef DEBUG
  236.     printf("taskIDlist-----------\n");
  237.     for(i=0;i<10;i++) printf("%dID=%d\n",i,taskOldID[i]);
  238.     #endif
  239.  
  240.     for(i=0;(taskButtonID[i]!=kobj) && (i<11);i++);
  241.  
  242.     #ifdef DEBUG
  243.     printf("select=%d(%d)\n",i,taskOldID[i]);
  244.     #endif
  245.  
  246.     if(i==10)
  247.     {
  248.         #ifdef DEBUG
  249.         printf("show task list\n");
  250.         #endif
  251.         MMI_CallMessage(MMI_GetApliId(), GM_TASKLIST, 0, 0 );
  252.     } else
  253.         if((trigger & MS_EVKEYONL40) || (trigger & MS_BTLEFTL40))
  254.             MMI_CallMessage(MMI_GetApliId(),GM_SWITCH,FALSE, taskOldID[i] );
  255.         else
  256.         {
  257.             MMI_CallMessage( taskOldID[i] ,GM_QUIT, 0, 0 );
  258.             taskListUpdateFlag=ENABLE ;
  259.             taskFlag=0;
  260.         }
  261.  
  262.     return NOERR ;
  263. }
  264.  
  265. /*    initDataGUI:MenuItemID[0]:MJ_MITEML40の呼び出し関数    */
  266. int    showAboutFunc(kobj, messId, argc, pev, trigger)
  267. int        kobj ;
  268. int        messId ;
  269. int        argc ;
  270. EVENT    *pev ;
  271. int        trigger ;
  272. {
  273.     sprintf(aboutMsg,"%d bytes free",EIN_checkMem());
  274.     //ベースダイアログを選択不可にする
  275.     //つないで表示
  276.     MMI_SendMessage(aboutDialogID ,MM_ATTACH , 1, dialogBaseHyperID);
  277.     MMI_SendMessage(aboutDialogID ,MM_SHOW , 0);
  278.     setAlertObj(aboutDialogID);
  279.  
  280.     aboutFlag = TRUE ;
  281.     return NOERR ;
  282. }
  283.  
  284. /*    initDataGUI:MenuItemID[8]:MJ_MITEML40の呼び出し関数    */
  285. int    packFunc(kobj, messId, argc, pev, trigger)
  286. int        kobj ;
  287. int        messId ;
  288. int        argc ;
  289. EVENT    *pev ;
  290. int        trigger ;
  291. {
  292.     return NOERR ;
  293. }
  294.  
  295. /*    initDataABOUTGUI:aboutDButtonID:MJ_DBUTTONL40の呼び出し関数    */
  296. int    aboutQuitFunc(kobj, messId, argc, pev, trigger)
  297. int        kobj ;
  298. int        messId ;
  299. int        argc ;
  300. EVENT    *pev ;
  301. int        trigger ;
  302. {
  303.     //消去して外す
  304.     MMI_SendMessage(aboutDialogID ,MM_ERASE , 0);
  305.     MMI_SendMessage(aboutDialogID ,MM_DETACH , 0);
  306.     //ベースダイアログを選択可にする
  307.     resetAlertObj();
  308.  
  309.     aboutFlag = FALSE ;
  310.     return NOERR ;
  311. }
  312.  
  313. /*    initDataGUI:MenuItemID[2]:MJ_MITEML40の呼び出し関数    */
  314. /*    initDataGUI:quitIconID:MJ_ICONL40の呼び出し関数    */
  315. int    quitFunc(kobj, messId, argc, pev, trigger)
  316. int        kobj ;
  317. int        messId ;
  318. int        argc ;
  319. EVENT    *pev ;
  320. int        trigger ;
  321. {
  322.     MMI_SetHaltFlag(TRUE);
  323.     quitFuncRet = NOERR ;
  324.  
  325.     return NOERR ;
  326. }
  327.  
  328. //-----------==================================----------------
  329.  
  330. /*    initDataCMNDGUI:commandfileDButtonID:MJ_DBUTTONL40の呼び出し関数    */
  331. int    commandFileDialogFunc(kobj, messId, argc, pev, trigger)
  332. int        kobj ;
  333. int        messId ;
  334. int        argc ;
  335. EVENT    *pev ;
  336. int        trigger ;
  337. {
  338.     #ifdef DEBUG
  339.     printf("to fdlgFunc\n");
  340.     #endif
  341.     if (fdlgFunc(buf) == 0) 
  342.     {
  343.         #ifdef DEBUG
  344.         printf("何も選択されてない\n");
  345.         #endif
  346.         return NOERR ;
  347.     }
  348.  
  349.     #ifdef DEBUG
  350.     printf("テキストに設定\n");
  351.     #endif
  352.     MMI_SendMessage( commandFileNameTextID, MM_SETTEXT, 3,buf, 127,TRUE);
  353.     MMI_SendMessage( commandFileNameTextID, MM_SHOW,0);
  354.  
  355.     return NOERR ;
  356. }
  357.  
  358. /*    initDataCMNDGUI:commandExecDButtonID:MJ_DBUTTONL40の呼び出し関数    */
  359. int    commandExecFunc(kobj, messId, argc, pev, trigger)
  360. int        kobj ;
  361. int        messId ;
  362. int        argc ;
  363. EVENT    *pev ;
  364. int        trigger ;
  365. {
  366.     char buf2[128];
  367.     char ext[4];
  368.     int i,k;
  369.  
  370.     MMI_SendMessage( commandFileNameTextID, MM_GETTEXT, 3,buf, 127,FALSE);
  371.  
  372.     //消去して外す
  373.     MMI_SendMessage(commandDialogID ,MM_ERASE , 0);
  374.     MMI_SendMessage(commandDialogID ,MM_DETACH , 0);
  375.     //ベースダイアログを選択可にする
  376.     resetAlertObj();
  377.  
  378.     //拡張子を調べて起動する
  379.     for(i=0;buf[i]!='\0' && buf[i]!=' ';i++) buf2[i] = buf[i];
  380.     buf2[i] = '\0';
  381.     ext[0]='\0';
  382.     EIN_fnameExt( buf2, ext );
  383.     #ifdef DEBUG
  384.     ext[3]='\0';
  385.     printf("拡張子:%s(%s)\n",ext,buf2);
  386.     #endif
  387.  
  388.     if(ext[0]=='E' && ext[1]=='X' && ext[2]=='G')
  389.     {
  390.         #ifdef DEBUG
  391.         printf("EXG起動\n");
  392.         #endif
  393.         MMI_CallMessage(MMI_GetApliId(),GM_INVOKE,TRUE,
  394.                                                 (int)buf);
  395.     } else
  396.     if(ext[0]=='E' && ext[1]=='X' && ext[2]=='P')
  397.     {
  398.         MMI_CallMessage(MMI_GetApliId(),GM_QUERYID,QM_DIRECTRY,( int )buf2 );
  399.         for(i=0;buf2[i]!='\0';i++) ;
  400.         buf2[i   ] = 'G';
  401.         buf2[i+ 1] = 'L';
  402.         buf2[i+ 2] = '.';
  403.         buf2[i+ 3] = 'E';
  404.         buf2[i+ 4] = 'X';
  405.         buf2[i+ 5] = 'G';
  406.         buf2[i+ 6] = ' ';
  407.         i+=7;
  408.         for(k=0;buf[k]!='\0';k++) buf2[i+k] = buf[k];
  409.         buf2[i+k] = '\0';
  410.         #ifdef DEBUG
  411.         printf("EXP overray:%s\n",buf2);
  412.         #endif
  413.         MMI_CallMessage(MMI_GetApliId(),GM_INVOKE,TRUE,(int)buf2);
  414.     } else
  415.     {    //    EXE・COM・BAT・COMMAND起動
  416.         #ifdef DEBUG
  417.         printf("EXE・COM・BAT・COMMAND:%s\n",buf);
  418.         #endif
  419.         system(buf);
  420.     }
  421.  
  422.     MMI_SendMessage( commandFileNameTextID, MM_SETTEXT, 3,NULL, 0,FALSE);
  423.  
  424.     return NOERR ;
  425. }
  426.  
  427. /*    initDataCMNDGUI:commandQuitIconID:MJ_ICONL40の呼び出し関数    */
  428. int    commandQuitFunc(kobj, messId, argc, pev, trigger)
  429. int        kobj ;
  430. int        messId ;
  431. int        argc ;
  432. EVENT    *pev ;
  433. int        trigger ;
  434. {
  435.     MMI_SendMessage( commandFileNameTextID, MM_SETTEXT, 3,NULL, 0,FALSE);
  436.  
  437.     //消去して外す
  438.     MMI_SendMessage(commandDialogID ,MM_ERASE , 0);
  439.     MMI_SendMessage(commandDialogID ,MM_DETACH , 0);
  440.     //ベースダイアログを選択可にする
  441.     resetAlertObj();
  442.  
  443.     return NOERR ;
  444. }
  445.  
  446.